//
//  SLDeviceSettingCell.m
//  SlockApp
//
//  Created by 凯朱 on 2024/7/29.
//

#import "SLDeviceSettingCell.h"

@implementation SLDeviceSettingModel
@end

@implementation SLDeviceSettingCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.contentView.backgroundColor = KBgColor_2;
    
}

-(void)setModel:(SLDeviceSettingModel *)model{
    _model = model;
    _titleLbl.text = model.title;
    _contentLbl.text = model.content;
    _descLbl.text = model.desc;
    _contentLbl.textColor = model.contentColor ? model.contentColor : KColor_placeholdar;
    
    _changeBtn.hidden = YES;
    _contentLbl.hidden = NO;
    _icon.hidden = NO;
    _iconWidth.constant = 8;
    _contentRightSpace.constant = 15;
    _descLbl.font = SYSTEMFONT(12);
    
    _changeBtn.on = [model.switchValue isEqualToString:@"1"];
    
    if (_model.style == 1) {
        
    }else if (_model.style == 2){
        _changeBtn.hidden = NO;
        _icon.hidden = YES;
        _contentLbl.hidden = YES;
        _descLbl.font = SYSTEMFONT(14);
        
    }else if (_model.style == 3){
        _icon.hidden = YES;
        _iconWidth.constant = 0;
        _contentRightSpace.constant = 0;
        _descLbl.font = SYSTEMFONT(14);
    }
    
}

- (IBAction)changeAction:(id)sender {
    if (self.switchBlock) {
        self.switchBlock(_changeBtn.isOn);
    }
}

+(CGFloat)cellHeightWith:(SLDeviceSettingModel *)model{
    CGFloat height = 50;
    if (model.desc.length > 0) {
        CGSize size = STRING_SIZE_FONT(kScreenWidth-70, model.desc, kFont(12));
        height += size.height+15;
    }
    return height;
}

@end
